package com.wgchao.mdmp.common;

import org.springframework.validation.BindingResult;
import org.springframework.validation.FieldError;

/**
 * @作者：wgchao
 * @时间：18:56 2019/10/28 0028
 * @用途：
 **/
public class BindingError {
    public static String error(BindingResult bindingResult){
        if(bindingResult.hasErrors()){
            String error = "";
            for (FieldError fieldError : bindingResult.getFieldErrors()) {
                error += (fieldError.getDefaultMessage()+",");
            }
            return error;
        }
        return null;
    }
}
